<?php
/**
 * @Notes:【】
 * @Date: 2022-06-25 23:22
 */

namespace App\Controller\Admin\Product;

use App\Controller\AbstractController;
use App\Service\Product\ProductReplyService;
use App\Service\Product\ProductService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @Notes:【】
 * @Date: 2022-06-25 23:23
 * @ApiController(prefix="admin/product/product_reply")
 */
class ProductReplyController extends AbstractController
{
    /**
     * @Inject()
     * @var ProductReplyService
     */
    protected $service;


    /**
     * @Notes:【】
     * @Date: 2022-06-27 0:59
     * @PostApi(path="lists")
     * @FormData(key="keyword",rule="nullable")
     * @FormData(key="category_id",rule="nullable")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->service->lists($params);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-25 23:28
     * @PostApi(path="add")
     * @FormData(key="cate_id",rule="Required",default="0")
     * @FormData(key="store_name",rule="Required",default="")
     * @FormData(key="keyword",rule="nullable",default="0")
     * @FormData(key="slider_image",rule="required")
     * @FormData(key="unit_name",rule="required")
     * @FormData(key="description",rule="required")
     * @FormData(key="freight",rule="required")
     * @FormData(key="postage",rule="nullable",default="0")
     * @FormData(key="is_show",rule="required")
     * @FormData(key="spec_type",rule="required")
     * @FormData(key="attrs",rule="required")
     * @FormData(key="attrData",rule="required")
     * @FormData(key="temp_id",rule="required")
     */
    public function add()
    {
        $params = $this->getParams(false);
        $this->service->add($params);
        _GetLastSql(1);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-25 23:28
     * @PostApi(path="edit")
     * @FormData(key="id")
     * @FormData(key="cate_id",rule="Required",default="0")
     * @FormData(key="store_name",rule="Required",default="")
     * @FormData(key="keyword",rule="nullable",default="0")
     * @FormData(key="slider_image",rule="required")
     * @FormData(key="unit_name",rule="required")
     * @FormData(key="description",rule="required")
     * @FormData(key="freight",rule="required")
     * @FormData(key="postage",rule="nullable",default="0")
     * @FormData(key="is_show",rule="required")
     * @FormData(key="spec_type",rule="required")
     * @FormData(key="attrs",rule="required")
     * @FormData(key="attrData",rule="required")
     * @FormData(key="temp_id",rule="required")
     */
    public function edit()
    {
        $params = $this->getParams(false);
        $this->service->edit($params->get('id'), $params->except('id'));
        _GetLastSql(1);
    }


    /**
     * @Notes:【】
     * @Date: 2022-07-02 16:59
     * @PostApi(path="detail")
     * @FormData(key="id")
     */
    public function detail()
    {
        $id = $this->getParams()->get('id');
        $data = $this->service->detail($id);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @User: zwc
     * @Date: 2022/6/29 13:43
     * @PostApi(path="header")
     */
    public function header()
    {
        $params = $this->getParams(false);
        $data = $this->service->getHeader();
        _SUCCESS($data);
    }
}